<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.example.pojo.Product" %>
<%@ page import="java.util.List" %>

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>添加商品 - MobileWorld</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f8f9fa;
            overflow-x: hidden;
        }
        header {
            background-color: #0078D7;
            color: white;
            text-align: center;
            padding: 1.5rem;
            animation: slideIn 0.8s ease-out;
        }
        header h1 {
            margin: 0;
        }
        .container {
            max-width: 800px;
            margin: 20px auto;
            padding: 1.5rem;
            background: #fff;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            opacity: 0;
            animation: fadeInUp 1s forwards;
        }
        .message {
            padding: 10px;
            margin-bottom: 20px;
            border-radius: 5px;
            font-size: 0.9rem;
        }
        .message.success {
            background-color: #d4edda;
            color: #155724;
        }
        .message.error {
            background-color: #f8d7da;
            color: #721c24;
        }
        form {
            display: flex;
            flex-direction: column;
            gap: 1rem;
            margin-bottom: 2rem;
        }
        label {
            font-weight: bold;
        }
        input[type="text"], input[type="number"], button {
            padding: 0.8rem;
            font-size: 1rem;
            border: 1px solid #ddd;
            border-radius: 5px;
            outline: none;
            transition: border-color 0.3s ease, transform 0.2s ease-in-out;
        }
        input[type="text"]:focus, input[type="number"]:focus {
            border-color: #0078D7;
            transform: scale(1.02);
        }
        button {
            background-color: #0078D7;
            color: white;
            cursor: pointer;
            border: none;
            border-radius: 5px;
            padding: 0.8rem;
            font-size: 1rem;
            transition: background-color 0.3s ease, transform 0.3s ease-in-out;
        }
        button:hover {
            background-color: #005bb5;
            transform: scale(1.05);
        }
        button:active {
            transform: scale(1);
        }
        .back-buttons {
            display: flex;
            gap: 10px;
            margin-top: 20px;
            justify-content: center;
        }
        .back-buttons a {
            background-color: #ffffff;
            color: #0078D7;
            border: 2px solid #0078D7;
            border-radius: 5px;
            padding: 0.5rem 1rem;
            font-size: 0.9rem;
            text-decoration: none;
            font-weight: bold;
            transition: all 0.3s ease;
            text-align: center;
        }
        .back-buttons a:hover {
            background-color: #0078D7;
            color: white;
        }
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        @keyframes slideIn {
            from {
                transform: translateY(-50px);
                opacity: 0;
            }
            to {
                transform: translateY(0);
                opacity: 1;
            }
        }
    </style>
</head>
<body>
<header>
    <h1>添加商品</h1>
</header>
<div class="container">
    <% if (request.getAttribute("message") != null) { %>
    <div class="message success"><%= request.getAttribute("message") %></div>
    <% } %>
    <% if (request.getAttribute("error") != null) { %>
    <div class="message error"><%= request.getAttribute("error") %></div>
    <% } %>
    <form action="products" method="post">
        <input type="hidden" name="action" value="add">
        <label for="name">商品名称：</label>
        <input type="text" id="name" name="name" placeholder="请输入商品名称" required>
        <label for="price">价格：</label>
        <input type="number" step="0.01" id="price" name="price" placeholder="请输入商品价格" required>
        <label for="stock">库存：</label>
        <input type="number" id="stock" name="stock" placeholder="请输入商品库存" required>
        <button type="submit">添加商品</button>
    </form>

    <div class="back-buttons">
        <a href="products">返回商品页面</a>
        <a href="index.jsp">返回首页</a>
    </div>
</div>
</body>
</html>
